package com.ics.web.controller.travelstar.controller;

import com.ics.common.core.controller.BaseController;
import com.ics.common.core.domain.AjaxResult;
import com.ics.web.controller.travelstar.domain.TiresAsset;
import com.ics.web.controller.travelstar.dto.TiresAssetDTO;
import com.ics.web.controller.travelstar.service.ITiresAssetService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * @author shaoly
 * @description
 * @ClassName TbTiresAssetController.java
 * @createTime 2024年09月23日 20:25:48
 */
@RestController
@RequestMapping("/tires/asset")
public class TbTiresAssetController extends BaseController {

    @Resource
    private ITiresAssetService assetService;


    /**
     * 资产列表
     */
    @ApiOperation("资产列表")
    @GetMapping("/list")
    public AjaxResult list(TiresAssetDTO assetDTO) {
        return success(assetService.listPage(assetDTO));
    }


    /**
     * 资产详情
     */
    @ApiOperation("资产详情")
    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(assetService.getById(id));
    }

    /**
     * 资产新增
     */
    @ApiOperation("资产新增")
    @PostMapping("/save")
    public AjaxResult save(@RequestBody TiresAsset tiresAsset) {
        return toAjax(assetService.saveOrUpdate(tiresAsset));
    }


    /**
     * 资产删除
     */
    @ApiOperation("资产删除")
    @PostMapping("/remove")
    public AjaxResult remove(@RequestParam("ids") String ids) {
        return toAjax(assetService.removeByIds(Arrays.asList(ids.split(","))));
    }

}
